from flask import Flask, jsonify, request
import json
app = Flask(__name__)


@app.route('/')
def index():
    return 'Hello World!'


@app.route("/api/test", methods=["GET"])
def get_test():
    dict = {"data": "test",
            "status": 200}
    return json.dumps(dict)


@app.route("/api/register", methods=['POST'])
def user_register():
    """注册用户"""
    request_data = request.get_json()
    print(request_data)
    dict = {}
    dict["data"] = "register successfully!"
    dict["status"] = 200
    return json.dumps(dict)
    


@app.route("/api/login", methods=['POST'])
def user_login():
    """登录用户"""
    request_data = request.get_json()
    print(request_data)
    dict = {}
    dict["data"] = "login successfully!"
    dict["status"] = 401
    return json.dumps(dict)